home *** CD-ROM | disk | FTP | other *** search
/ Mac Power 1997 December / MACPOWER-1997-12.ISO.7z / MACPOWER-1997-12.ISO / AMUG / PROGRAMMING / Raven 1.2.sit / Raven 1.2 / Source / Foundation / OS / ZNotify.h < prev    next >
Text File  |  1997-01-10  |  3KB  |  102 lines

  1. /*
  2.  *  File:       ZNotify.h
  3.  *  Summary:       A wrapper around the Notification Manager.
  4.  *  Written by: Jesse Jones
  5.  *
  6.  *  Copyright ゥ 1996 Jesse Jones. 
  7.  *    For conditions of distribution and use, see copyright notice in ZTypes.h  
  8.  *
  9.  *  Change History (most recent first):    
  10.  *
  11.  *         <->     1/09/96    JDJ        Created
  12.  */
  13.  
  14. #pragma once
  15.  
  16. #include <Notification.h>
  17.  
  18. #include <String>
  19.  
  20. #include <ZListener.h>
  21. #include <ZStateBroadcaster.h>
  22.  
  23.  
  24. // ===================================================================================
  25. //    class TNotify
  26. // ===================================================================================
  27. class TNotify : public MListener<SStateMessage> {
  28.  
  29. //-----------------------------------
  30. //    Initialization/Destruction
  31. //
  32. protected:
  33.     virtual             ~TNotify();
  34.                         // Protected to prevent allocation on the stack.
  35.     
  36. public:
  37.                           TNotify(ResID iconID, ResID soundID = 0, bool useMark = true);
  38.                           // Defaults to the "polite" notification: an icon blinking in
  39.                           // the menu bar with the app's name marked. If iconID is 0 no
  40.                           // icon is displayed. If iconID is greater than 0 an 'ics8' or
  41.                           // 'ics4' resource is used. If soundID is -1 the system alert 
  42.                           // sound is played. If soundID is greater than 0 a 'snd ' 
  43.                           // resource is played.
  44.  
  45.                           TNotify(const string& mesg, ResID iconID, ResID soundID = -1, bool useMark = true);
  46.                         // The obnoxious notification: an alert is displayed in whatever
  47.                         // app happens to be frontmost. This should be used sparingly.
  48.                         
  49.                           TNotify(const string& mesg, ResID soundID = 0);
  50.                           // Displays an alert without messing with the menu bar. This
  51.                           // can be used when you want to display an alert in things like
  52.                           // Drag Manager callbacks (note that you cannot use this in a 
  53.                           // VBL or Time Manager callback because the class doesn't use 
  54.                           // an interrupt safe version of operator new).
  55.                                                     
  56.       virtual void         Post();
  57.                           // To use a TNotify object first create it on the heap and then
  58.                           // call Post. The object will be deleted automatically.
  59.                           
  60. private:
  61.                         TNotify(const TNotify& rhs);
  62.                         
  63.             TNotify&     operator=(const TNotify& rhs);
  64.  
  65. //-----------------------------------
  66. //    New API
  67. //
  68. public:
  69.     virtual void         HandleCallback();
  70.     
  71. protected:
  72.     virtual void         OnCallback()                            {}
  73.                         // This will be called after the sound has played or the user 
  74.                         // dismisses the alert. Note that Inside Mac says that this should 
  75.                         // not cause anything to be drawn or otherwise affect the interface.
  76.                 
  77. //-----------------------------------
  78. //    Inherited API
  79. //
  80. protected:
  81.     virtual void         OnBroadcast(const SStateMessage& mesg);
  82.                         // Deletes the object if message is kResumingApp.
  83.  
  84. //-----------------------------------
  85. //    Internal API
  86. //
  87. private:
  88.     static    pascal void DoCallback(NMRec* record);
  89.     
  90.             void         Init(const string& mesg, ResID iconID, ResID soundID, bool useMark);
  91.             
  92. //-----------------------------------
  93. //    Member data
  94. //
  95. public:
  96.     NMRec            mRecord;    
  97.     unsigned char*    mText;
  98.     
  99.     bool            mCalledFromForeground;
  100.     bool            mInstalled;
  101. };
  102.